package com.sgzn.sgpay.web.controller;

import com.sgzn.sgpay.model.request.SgsRefreshPrivRequest;
import com.sgzn.sgpay.model.response.SgsResultResponse;
import com.sgzn.sgpay.service.SgsMchPrivManageService;
import com.sgzn.sgpay.web.handle.AssembleCommonHandle;
import com.sgzn.sgpay.web.request.Impl.MchPrivilegeRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 商户权限管理控制器
 * @author zhongzhongyong
 * @version Id: MchPrivilegeController.java, v 0.1 2018/5/28 23:05 zhongzhongyong Exp $$
 */
@Slf4j
@Controller
public class MchPrivilegeController {
    @Resource
    private SgsMchPrivManageService sgsMchPrivManageService;
    @Resource
    private AssembleCommonHandle assembleCommonHandle;
    /**
     * 刷新主商户的权限
     * @return
     */
    @RequestMapping("/admin/priv/refresh")
    @ResponseBody
    public SgsResultResponse<String> refreshMainMchPriv(MchPrivilegeRequest request) {
        return this.sgsMchPrivManageService.refreshMainMchPriv(assembleRefreshRequest(request));
    }

    private SgsRefreshPrivRequest assembleRefreshRequest(MchPrivilegeRequest request) {
        SgsRefreshPrivRequest sgsBaseRequest = new SgsRefreshPrivRequest();
        this.assembleCommonHandle.assemble(request, sgsBaseRequest);
        return sgsBaseRequest;
    }

}

